|
|
|
|
|
|
|
Further, let's examine the transfer() method: |
|
|
|
|
|
|
|
|
transfer(ByVal argAmount, ByVal argAccountNumber1, _
ByVal argAccountNumber2) |
|
|
|
|
|
|
|
|
For simplicity's sake, ignore the types of each argument. argAmount is the amount of money to be transferred between accounts. Assume that argAccountNumber1 refers to an interest-bearing checking account and that argAccountNumber2 refers to a savings account. Assume that the object, theBankHolding, knows how to map each type of account to its corresponding methods and that a transfer is implemented as a withdrawal from the first account and a deposit to the second account. In code, a client object would view the transfer operation as follows: |
|
|
|
|
|
|
|
|
'Declare theBankHolding object
Global theBankHolding As New BankHolding
'Place in some event or method
Dim acknowledgment As Integer
acknowledgment = theBankHolding.transfer(100, 2001, 3002) |
|
|
|
|
|
|
|
|
Subsystems that expose public interface classes operate in a manner to provide a similar result but add more complexity. For instance, modifying your code, you have the following: |
|
|
|
|
|
|
|
|
Public theInterestBearingChecking As New _ InterestBearingChecking
Public theSavings As New Savings
'Declare theBankHolding object
Global theBankHolding As New BankHolding
'Place in some event or method
Dim acknowledgment As Integer
acknowledgment = _
theBankHolding.theInterestBearingChecking.withdraw(100)
acknowledgment = _
theBankHolding.theSavings.deposit(100) |
|
|
|
|
|
|
|
|
Notice that theInterestBearingChecking and theSavings are declared as Public within BankHolding. To use classes that act as interface agents for a subsystem, you must |
|
|
|
|
|